using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

using ClientLib;

namespace TinyCClient
{
    public class TinyUser
    {
        public TinyUser(string name)
        {
            m_userName = name;
        }
        string m_userName;
        string m_region;
        public void ProcessReceivedMsg()
        {
            switch (m_runtime.g_TCPclient.getMsgIndex())
            {
                case GlobalDefine.CLIENT_ACTION:
                    {
                        switch (m_runtime.g_TCPclient.getMsgItem())
                        {
                            case GlobalDefine.CLIENT_SEND_TXTMSG:
                                {
                                    if (m_textTalkForm == null || m_textTalkForm.IsDisposed)
                                    {
                                        m_textTalkForm = new TextTalk();
                                        m_textTalkForm.setTCPClient(m_runtime.g_TCPclient);
                                        m_textTalkForm.setRuntime(m_runtime);
                                        m_textTalkForm.Text = m_userName;
                                        m_textTalkForm.Show();
                                    }
                                    m_textTalkForm.ProcessReceivedMsg();
                                } break;
                            case GlobalDefine.CLIENT_SEND_TXTMSG_FINISHED:
                                {
                                    if (m_textTalkForm == null || m_textTalkForm.IsDisposed)
                                    {
                                        m_textTalkForm = new TextTalk();
                                        m_textTalkForm.setTCPClient(m_runtime.g_TCPclient);
                                        m_textTalkForm.setRuntime(m_runtime);
                                        m_textTalkForm.Text = m_userName;
                                        m_textTalkForm.Show();
                                    }
                                    m_textTalkForm.ProcessReceivedMsg();
                                } break;
                            default:
                                break;
                        };
                    } break;
                default:
                    break;
            };

            
            return;
        }
        public void setRunTime( ClientLib.TinyClientRuntime rt)
        {
            m_runtime = rt;
        }
        public void showTextTalkForm()
        {
            if(m_textTalkForm == null||m_textTalkForm.IsDisposed)
            {
                m_textTalkForm = new TextTalk();
                m_textTalkForm.setTCPClient(m_runtime.g_TCPclient);
                m_textTalkForm.setRuntime(m_runtime);
                m_textTalkForm.Text = m_userName;
                m_textTalkForm.Show();
            }

            m_textTalkForm.Activate();
        }
        public void showUserInfoForm()
        {
           /* if (m_textTalkForm == null || m_textTalkForm.IsDisposed)
            {
                m_textTalkForm = new TextTalk();
                m_textTalkForm.setTCPClient(m_runtime.g_TCPclient);
                m_textTalkForm.setRuntime(m_runtime);
                m_textTalkForm.Text = m_userName;
                m_textTalkForm.Show();
            }

            m_textTalkForm.Activate();*/
        }
         TextTalk m_textTalkForm;
         UserInfo m_userInfoForm;
        ClientLib.TinyClientRuntime m_runtime;
    }
}
